<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>数据查询</title>
<link href="<%=path%>/static/usercss/css/all.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<%=path%>/static/js/jquery-3.2.1.js"></script>
<!--[if IE]>
<script>
(function(){if(!/*@cc_on!@*/0)return;var e = "abbr,article,aside,audio,canvas,datalist,details,dialog,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(','),i=e.length;while(i--){document.createElement(e[i])}})()
</script>
<![endif]-->
</head>
<body>
<jsp:include page="/WEB-INF/web/includ/header.jsp"></jsp:include>
<section>
<div class="wrap">
<div class="section">
    <article id="datalist">
      <nav>
        <div class="seach">
        <form action="<%=path %>/web/userinfo/seachByTime" method="post" >
        	<div class="text-c"> 日期范围：
							<input style="margin-bottom:6px;" value="" name="beginTime" type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })" id="datemin" class="input-text Wdate" style="width:120px;">
							-
							<input style="margin-bottom:6px;" value="" name="endTime" type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })" id="datemax" class="input-text Wdate" style="width:120px;">
		
			 				<input type="submit" value="按时间查询"/>
			 				<!-- <a type="submit" href="javascript:void(0);">按时间查询</a>	 -->
			 		</div>
        
       <!--  <span>开始时间</span>
        <input name="starttime" type="date" value="请选择">
         <span>开始时间</span>
        <input name="stoptime" type="date" value="请选择">
    <a href="#">按时间查询</a> -->
    </form>
      </nav>
      <div id="title">
      <h1>我的数据列表</h1>
      <label>分类名称</label>
      <span><a href="<%=path%>/web/userinfo/addData">添加数据</a></span>
    </div>
    <datalist>
      <table border="0" cellpadding="0">
        <tr>
          <th>废弃物名称</th>
          <th>所属分类</th>
          <th>所在地</th>
          <th>开始时间</th>
          <th>结束时间</th>
          <th>废弃量</th>
          <th>回收量</th>
          <!-- <th>再利用量</th> -->
          <th>操作</th>
        </tr>
        <c:forEach items="${requestScope.dataList.list }" var="data" varStatus="stat">
        		<tr>
		          <td class="textleft">${data.rubbish.name }</td>
		          <td>${data.rubbish.secondtype.title }</td>
		          <td>${data.city.city_name }</td>
		          <td><fmt:formatDate value="${data.beginTime }" pattern="yyyy-MM-dd HH:mm"/></td>
		          <td><fmt:formatDate value="${data.endTime }" pattern="yyyy-MM-dd HH:mm"/></td>
		          
		          <c:if test="${!data.isDispose }">
		          <td>${data.count } ${data.unit.name }</td>
		          <td></td>
		          </c:if>
		          <c:if test="${data.isDispose }">
		          <td></td>
		          <td>${data.count } ${data.unit.name }</td>
		          </c:if>
		          <!-- <td></td> -->
		          <td><input type="hidden" value="${data.id }"><a id="change" href="javascript:void(0);">修改</a> <a onclick="delectOne(this,${data.id})" href="javascript:void(0);">删除</a></td>
		        </tr>
        </c:forEach>
        
         
      </table>
    </datalist>
    <div class="pagination ">
      <a href="<%=path%>/web/userinfo/dataList?id=${param.id}&pageNum=1" title="第一页">« 第一页</a>
      <a id="prev" href="<%=path%>/web/userinfo/dataList?id=${param.id}&pageNum=${param.pageNum-1<1?1:param.pageNum-1}" title="上一页">« 前一页</a>
      <c:forEach items="${requestScope.dataList.navigatepageNums }" var="page">
				<a id="page"
				<c:if test="${page==param.pageNum }">class="number current"</c:if>				
				 title="第${page}页" href="<%=path%>/web/userinfo/dataList?id=${param.id}&pageNum=${page}">${page}</a> 
			</c:forEach>
     
      <a href="<%=path%>/web/userinfo/dataList?id=${param.id}&pageNum=${param.pageNum+1>requestScope.dataList.pages?requestScope.dataList.pages:param.pageNum+1}" title="下一页">下一页 »</a>
      <a href="<%=path%>/web/userinfo/dataList?id=${param.id}&pageNum=${requestScope.dataList.pages}" title="最后页">最后 »</a>
    </div>
    </article>
  <jsp:include page="/WEB-INF/web/includ/aside.jsp"></jsp:include>
</div>
</div>
</section>
<script type="text/javascript" src="<%=path%>/static/managecss/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="<%=path%>/static/js/jquery-3.2.1.js"></script>
<script src="<%=path%>/static/managecss/lib/layer/2.4/layer.js"></script>
<script type="text/javascript">
	$(function() {
			
			if("${param.pageNum}"==""||"${param.pageNum}"<1){
				$("a[title=第1页]").attr("class","number current");
				
			}
			if("${param.pageNum}">"${requestScope.dataList.pages}"){
				$("a[title=第${requestScope.dataList.pages}页]").attr("class","number current");
				
			}
	})


	function delectOne(obj,id) {
		layer.confirm('确认要删除吗？',{
			  btn: ['确定', '取消'] //可以无限个按钮
		  ,
		}, function(index, layero){	
			
			$.ajax({
				type:'post',
				url:'<%=path%>/web/userinfo/dataDelect',
				data:{id:id},
				success:function(mes){					
					$(obj).parents("tr").remove();
					layer.close(index);
				}
			}); 
			
		}, function(index){
			  
			
		});
	 	
		
		
	}

	$(function() {
		$("a[id=change]").click(function() {
			  var id = $(this).prev().val();
				location.href="<%=path%>/web/userinfo/changeData?id="+id;
		});
	});


</script>

<jsp:include page="/WEB-INF/web/includ/footer.jsp"></jsp:include>
</body>
</html>
